package com.project.class4_11;

public class Test {
    public static void main(String[] args) {
        Man m = new Man();
        m.setTool(new Plane());
        m.play();
        m.setTool(new Car());
        m.play();
        m.setTool(new Ship());
        m.play();
    }
}

class Man{
    private Tool t;
    public void play(){
        t.move();
        System.out.println("游玩");
    }
    public void setTool(Tool t){
        this.t = t;
    }
}

interface Tool{
    public void move();
}

class Plane implements Tool{

    @Override
    public void move() {
        System.out.print("飞到目的地");
    }
}

class Car implements Tool{

    @Override
    public void move() {
        System.out.print("行驶到目的地");
    }
}

class Ship implements Tool{

    @Override
    public void move() {
        System.out.print("航行到目的地");
    }
}